/**
 * 随机生成模块
 */
layui.define(function (exports) {
    var MOD_NAME = 'bmsrdm';

    var BmsRdm = function () {
        var init = function(){

        }
    }

    BmsRdm.prototype.parse = function(date, format)
    {
        var dt = new Date(date);

        return dt.Format(format);
    }

    var chars = ['0','1','2','3','4','5','6','7','8','9'
        ,'A','B','C','D','E','F','G','H','I','J', 'K','L','M','N'
        ,'O','P','Q','R','S','T','U','V','W','X','Y','Z'
        ,'a','b','c','d','e','f','g','h','i','j', 'k','l','m','n'
        ,'o','p','q','r','s','t','u','v','w','x','y','z'];

    var call = {
        randomStr: function(prefix, len)
        {
            len = len || 10;
            prefix = prefix || 'BmsRdm-';

            var str = '';
            for (var i = 0; i < len; i++) {
                str += chars[Math.floor(Math.random() * chars.length)];
            }
            return prefix + str;
        }
    }

    /**
     * 随机生成带前缀的字符串
     * @param prefix
     */
    BmsRdm.prototype.randomStr = function(prefix, len){
        return call.randomStr(prefix, len);
    }

    var TablRdm = function(){
        // tableFilter 表格事件的过滤器
        this.tableFilter = undefined;
        // tableElemId表格的元素ID
        this.tableElemId = undefined;
        // reloadTblId 表格的重载标识ID
        this.reloadTableId = undefined;
        // reloadBtnId 提交搜索id
        this.reloadBtnId = undefined;
        // tableBarId 表格工具样ID
        this.tableBarId = undefined;
    };
    BmsRdm.prototype.randomTable = function(prefix, len)
    {
        var tabrdm = new TablRdm();
        tabrdm.tableFilter = call.randomStr(prefix, len);
        tabrdm.tableElemId = call.randomStr(prefix, len);
        tabrdm.reloadTableId = call.randomStr(prefix, len);
        tabrdm.reloadBtnId = call.randomStr(prefix, len);
        tabrdm.tableBarId = call.randomStr(prefix, len);
    }

    var bmsrdm = new BmsRdm();

    exports(MOD_NAME, bmsrdm);
})